
 function quickSort (arr,left,right) {
    if(right - left <= 0){
        return;
    }
    let li = left,ri = right;
    let minIndex = Math.floor((left + right)/2);
    while (li < ri ){

        while (arr[li] <= arr[minIndex] && li < minIndex){//注意元素相等情况
            li++;
        }
        while (arr[ri] >= arr[minIndex] && ri > minIndex){//注意元素相等情况
            ri--;
        }
        if(arr[li] > arr[ri]){
            swap(arr,li,ri);
        }
    }
    quickSort(arr,left,minIndex-1);
    quickSort(arr,minIndex+1,right);
}

function swap(arr,l,r) {
    let temp = arr[l];
    arr[l] = arr[r];
    arr[r] = temp;
}


let arr =  [-1, 0, 2, 3, 3, 7, 8, 9,6,10,4,5,7];
quickSort(arr,0,arr.length-1);
console.log(arr);
